﻿using Gp.GCX;
using Gp.Scripts.Core;
using Helpers;
using QFramework;
using TMPro;
using UnityEngine;

namespace Gp.Scripts.GUI
{
    public class UnitTurnCountDisplayUI : UnitSubObject, IController
    {
        [SerializeField] private Transform window;
        [SerializeField] private TMP_Text numberText;

        private void Start()
        {
            window.Hide();
        }

        protected override void OnInit()
        {
            // UnitReference.RegisterEvent<TurnCountChange>(args =>
            // {
            //     window.Show();
            //     numberText.text = args.TurnCount.ToString();
            // });

            UnitReference.RegisterEvent<Event_Unit.Death>(_ => window.Hide());
            this.RegisterEvent<Event_BattleEnd>(_ => window.Hide());
        }


        private void LateUpdate()
        {
            if (ObjectHelper.MainCamera == null) return;

            Quaternion q = Quaternion.identity;
            q.SetLookRotation(ObjectHelper.MainCamera.transform.forward, ObjectHelper.MainCamera.transform.up);
            transform.rotation = q;
        }


        public IArchitecture GetArchitecture()
        {
            return MainArchitecture.Interface;
        }
    }
}